home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 33.6 KB | 1,024 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWFrming.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWFRMING_H
- #include "FWFrming.h"
- #endif
-
- #ifndef FWPARTNG_H
- #include "FWPartng.h"
- #endif
-
- #ifndef FWPXYFRM_H
- #include "FWPxyFrm.h"
- #endif
-
- #ifndef FWPROXY_H
- #include "FWProxy.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWSLCING_H
- #include "FWSlcing.h"
- #endif
-
- #ifndef FWTRACKR_H
- #include "FWTrackr.h"
- #endif
-
- #ifndef FWFRMINF_H
- #include "FWFrmInf.h"
- #endif
-
- #ifndef FWPRTITE_H
- #include "FWPrtIte.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWCURSOR_H
- #include "FWCursor.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_ODInfo_xh
- #include <Info.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment fw_embedding
- #endif
-
- FW_DEFINE_CLASS_M1(FW_CEmbeddingFrame, FW_CFrame)
-
- //========================================================================================
- // class FW_CEmbeddingFrame
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::FW_CEmbeddingFrame
- //----------------------------------------------------------------------------------------
-
- FW_CEmbeddingFrame::FW_CEmbeddingFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_CEmbeddingPart* part) :
- FW_CFrame(ev, odFrame, presentation, part),
- fProxyFrames(NULL)
- {
- fProxyFrames = new FW_CPrivOrderedCollection;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::~FW_CEmbeddingFrame
- //----------------------------------------------------------------------------------------
-
- FW_CEmbeddingFrame::~FW_CEmbeddingFrame()
- {
- if (fProxyFrames)
- {
- Environment* ev = somGetGlobalEnvironment();
- FW_CProxyFrame* proxyFrame = (FW_CProxyFrame*)fProxyFrames->First();
- while (proxyFrame != NULL)
- {
- PrivRemoveProxyFrame(ev, proxyFrame);
- proxyFrame = (FW_CProxyFrame*)fProxyFrames->First();
- }
-
- delete fProxyFrames;
- fProxyFrames = NULL;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::EmbeddedFrameRequested
- //----------------------------------------------------------------------------------------
-
- ODFrame* FW_CEmbeddingFrame::EmbeddedFrameRequested(Environment *ev,
- ODFrame* odBaseFrame,
- ODShape* frameShape,
- ODPart* embeddedPart,
- ODTypeToken viewType,
- ODTypeToken presentation,
- ODBoolean isOverlaid)
- {
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::GetProxy
- //----------------------------------------------------------------------------------------
-
- FW_MProxy* FW_CEmbeddingFrame::GetProxy(Environment *ev,
- ODFrame* embeddedFrame) const
- {
- FW_ASSERT(embeddedFrame != NULL);
-
- ODID embeddedFrameID = embeddedFrame->GetID(ev);
-
- FW_CFrameProxyFrameIterator iter(this);
- for (FW_CProxyFrame* proxyFrame = iter.First(); iter.IsNotComplete(); proxyFrame = iter.Next())
- {
- if (proxyFrame->GetFrameID(ev) == embeddedFrameID)
- return proxyFrame->GetProxy(ev);
- }
-
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::PrivCreateEmbeddedFrame
- //----------------------------------------------------------------------------------------
- // the returned proxyframe should be release by the caller
-
- FW_DECLARE_THROW_POINT (FW_CEmbeddingFrame_PrivCreateEmbeddedFrame);
-
- FW_CProxyFrame* FW_CEmbeddingFrame::PrivCreateEmbeddedFrame(Environment* ev,
- ODType frameType,
- ODPart *embeddedODPart,
- FW_MProxy* proxy, // can be null
- ODShape* frameShape,
- ODCanvas* biasCanvas, // can be null
- ODTypeToken viewType,
- ODTypeToken presentationType,
- ODID frameGroupID,
- FW_Boolean isOverlaid,
- FW_Boolean subFrame)
- {
- FW_CEmbeddingPart* embeddingPart = (FW_CEmbeddingPart*)GetPart(ev);
-
- ODStorageUnit* su = embeddingPart->GetStorageUnit(ev);
-
- if (presentationType == 0)
- presentationType = GetPart(ev)->GetSession(ev)->Tokenize(ev, kODPresDefault);
-
- // ----- create the new frame
- FW_CAcquiredODFrame embeddedODFrame = su->GetDraft(ev)->CreateFrame(ev,
- frameType,
- GetODFrame(ev),
- frameShape,
- biasCanvas,
- embeddedODPart,
- viewType,
- presentationType,
- subFrame,
- isOverlaid);
-
- embeddedODFrame->SetFrameGroup(ev, frameGroupID);
-
- // Testing: can the caller deal with this method failing?
- FW_CHECK_THROW_POINT (FW_CEmbeddingFrame_PrivCreateEmbeddedFrame);
-
- // ----- Create the proxyFrame for this embedded frame -----
- FW_CProxyFrame* proxyFrame = new FW_CProxyFrame(ev, GetPart(ev), proxy, this, embeddedODFrame);
-
- return proxyFrame;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::PrivCreateEmbeddedFacets
- //----------------------------------------------------------------------------------------
-
- FW_DECLARE_THROW_POINT (FW_CEmbeddingFrame_PrivCreateEmbeddedFacets);
-
- void FW_CEmbeddingFrame::PrivCreateEmbeddedFacets(Environment* ev, FW_MProxy* proxy, FW_CProxyFrame* proxyFrame)
- {
- FW_ASSERT(proxy);
- FW_ASSERT(proxyFrame);
-
- FW_CFrameFacetIterator ite(ev, this);
- // Exception Handling: as with all loops, if one pass fails we need to undo the
- // effects of the previous ones.
- FW_TRY {
- for (ODFacet* containingFacet = ite.First(ev); ite.IsNotComplete(ev); containingFacet = ite.Next(ev))
- {
- PrivCreateEmbeddedFacet(ev, proxy, proxyFrame, containingFacet);
-
- // Testing: what happens if one facet is created and then we fail? (as
- // if we tried and failed to create two facets?)
- FW_CHECK_THROW_POINT (FW_CEmbeddingFrame_PrivCreateEmbeddedFacets);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING () {
- PrivRemoveEmbeddedFacets (ev, proxyFrame);
- FW_THROW_SAME ();
- }
- FW_CATCH_END
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::PrivCreateEmbeddedFacet
- //----------------------------------------------------------------------------------------
-
- FW_DECLARE_THROW_POINT (FW_CEmbeddingFrame_PrivCreateEmbeddedFacet);
-
- void FW_CEmbeddingFrame::PrivCreateEmbeddedFacet(Environment* ev, FW_MProxy* proxy, FW_CProxyFrame* proxyFrame, ODFacet* embeddingFacet)
- {
- FW_ASSERT(proxy);
- FW_ASSERT(proxyFrame);
- FW_ASSERT(embeddingFacet);
-
- if (!proxyFrame->IsFrameInMemory(ev))
- return;
-
- ODFrame* embeddedFrame = proxyFrame->GetFrame(ev);
-
- FW_CAcquiredODShape proposedClipShape = FW_CopyAndRelease(ev, embeddedFrame->AcquireFrameShape(ev, NULL));
-
- /*
- // [HLX] DR4 bug??? I have to be sure that the embedded part is loaded before created embedded
- // facet otherwise the embedded part FacetAdded method is going to be called twice. Once by
- // ODFrame::AcquirePart and once by ODFrame::FacetAdded
- FW_CAcquiredODPart embeddedPart = embeddedFrame->AcquirePart(ev);
- // [HLX] DR4 bug???
- */
-
- this->CreateEmbeddedFacet(ev,
- embeddingFacet,
- proxy,
- embeddedFrame,
- proposedClipShape);
-
- // ----- I need to go through all the embedded facets because I don't know how many where added -----
- // For example, if we embedded Puzzle part then it would create 9 embedded facets. That's
- // why CreateEmbeddedFacet doesn't return a pointer to the "one" created facet.
- FW_TRY {
- FW_CFacetIterator ite(ev, embeddingFacet, kODChildrenOnly, kODFrontToBack);
- for (ODFacet* embeddedFacet = ite.First(ev); ite.IsNotComplete(ev); embeddedFacet = ite.Next(ev))
- {
- if (embeddedFacet->GetFrame(ev) == embeddedFrame)
- {
- embeddedFacet->SetSelected(ev, proxy->GetSelectState(ev));
- this->EmbeddedFacetAdded(ev, embeddedFacet);
- proxy->PrivEmbeddedFacetAdded(ev);
- }
-
- // Testing: what happens if one facet is created and then we fail? (as
- // if we tried and failed to create two facets?)
- FW_CHECK_THROW_POINT (FW_CEmbeddingFrame_PrivCreateEmbeddedFacet);
- }
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING () {
- // This actually removes embedded facets of the proxyFrame *in* this embeddingFacet
- PrivRemoveEmbeddedFacet (ev, proxyFrame, embeddingFacet);
- FW_THROW_SAME ();
- }
- FW_CATCH_END
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::PrivRemoveEmbeddedFacets
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::PrivRemoveEmbeddedFacets(Environment* ev, FW_CProxyFrame* proxyFrame)
- {
- FW_CFrameFacetIterator ite(ev, this);
- for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
- PrivRemoveEmbeddedFacet(ev, proxyFrame, facet);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::PrivRemoveEmbeddedFacet
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::PrivRemoveEmbeddedFacet(Environment* ev, FW_CProxyFrame* proxyFrame, ODFacet* embeddingFacet)
- {
- FW_ASSERT(proxyFrame != NULL);
- FW_ASSERT(embeddingFacet != NULL);
-
- if (!proxyFrame->IsFrameInMemory(ev)) // if not in memory should not have any facets
- return;
-
- ODFrame* embeddedFrame = proxyFrame->GetFrame(ev);
-
- FW_CPrivOrderedCollection tempCollect;
-
- // Attention: Do not try to iterate through all the facets of the embedded frame because
- // if we are in a middle of a drag&drop, the embedded frame may already have been stripped
- // of all its facets (in the case where the frame is reused, SetContainingFrame is called
- // which remove all the facets of the frame). But the hierarchy of facets is still there
- FW_CFacetIterator ite(ev, embeddingFacet, kODChildrenOnly, kODFrontToBack);
- ODFacet* facet;
- for (facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
- {
- if (facet->GetFrame(ev) == embeddedFrame)
- tempCollect.AddLast(facet);
- }
-
- FW_MProxy* proxy = proxyFrame->GetProxy(ev);
-
- FW_COrderedCollectionIterator ite2(&tempCollect);
- for (facet = (ODFacet*)ite2.First(); ite2.IsNotComplete(); facet = (ODFacet*)ite2.Next())
- {
- this->EmbeddedFacetRemoved(ev, facet);
- proxy->PrivEmbeddedFacetRemoved(ev);
-
- embeddingFacet->RemoveFacet(ev, facet);
- delete facet;
- }
-
- // RemoveAll will be called by the destructor of tempCollect
- // tempCollect.RemoveAll();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::Activate
- //----------------------------------------------------------------------------------------
- // [HLX] Temporary hack. To be removed (See FW_CFrame::FocusChanged)
-
- FW_Boolean FW_CEmbeddingFrame::Activate(Environment* ev)
- {
- FW_Boolean result = FW_CFrame::Activate(ev);
-
- if (result)
- {
- FW_CFrameProxyFrameIterator iter(this);
- for (FW_CProxyFrame* proxyFrame = iter.First(); iter.IsNotComplete(); proxyFrame = iter.Next())
- {
- if (proxyFrame->IsFrameInMemory(ev) && proxyFrame->GetProxy(ev)->GetSelectState(ev))
- {
- FW_CODFrameFacetIterator ite(ev, proxyFrame->GetFrame(ev));
- for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
- {
- facet->SetSelected(ev, TRUE);
- }
- }
- }
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::Deactivate
- //----------------------------------------------------------------------------------------
- // [HLX] Temporary hack. To be removed (See FW_CFrame::FocusChanged)
-
- void FW_CEmbeddingFrame::Deactivate(Environment* ev)
- {
- FW_CFrame::Deactivate(ev);
-
- FW_CFrameFacetIterator iter(ev, this);
- for (ODFacet* facet = iter.First(ev); iter.IsNotComplete(ev); facet = iter.Next(ev))
- {
- FW_CFacetIterator ite(ev, facet, kODChildrenOnly, kODFrontToBack);
- for (ODFacet* embeddedFacet = ite.First(ev); ite.IsNotComplete(ev); embeddedFacet = ite.Next(ev))
- {
- embeddedFacet->SetSelected(ev, FALSE);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::GetPart
- //----------------------------------------------------------------------------------------
-
- FW_CEmbeddingPart* FW_CEmbeddingFrame::GetPart(Environment *ev) const
- {
- return (FW_CEmbeddingPart*)FW_CFrame::GetPart(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::FrameAdded
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::FrameAdded(Environment* ev, FW_Boolean fromStorage)
- {
- // ----- Call inherited -----
- FW_CFrame::FrameAdded(ev, fromStorage);
-
- // ----- Attach to myself all the proxyFrame having myself as container -----
- if (fromStorage)
- {
- FW_CPartProxyFrameIterator ite(GetPart(ev));
- for (FW_CProxyFrame* proxyFrame = ite.First(); ite.IsNotComplete(); proxyFrame = ite.Next())
- {
- if (proxyFrame->GetContainingFrameID(ev) == this->GetID(ev))
- {
- this->PrivAddProxyFrame(ev, proxyFrame);
-
- // [HLX] for now lets make them all visible
- proxyFrame->GetFrame(ev);
- }
- }
- }
- else
- {
- PrivAttachOrphans(ev);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::PageEmbeddedFrames
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::PageEmbeddedFrames(Environment* ev)
- {
- if (!GetPart(ev)->IsSupportingFramePaging(ev))
- return;
-
- /*
- FW_CFrameProxyFrameIterator ite1(this);
- for (FW_CProxyFrame* proxyFrame = ite1.First(); ite1.IsNotComplete(); proxyFrame = ite1.Next())
- {
- FW_CRect bounds;
- proxyFrame->GetProxy(ev)->GetProxyBounds(ev, this, bounds);
-
- FW_Boolean purgeable = TRUE;
- FW_CFrameFacetIterator ite(ev, this);
- for (ODFacet* facet = ite.First(ev); ite.IsNotComplete(ev); facet = ite.Next(ev))
- {
- if (proxyFrame->IsVisible(ev, facet, bounds))
- {
- purgeable = FALSE;
- break;
- }
- }
-
- proxyFrame->SetPurgeable(ev, purgeable);
- }
- */
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::PrivAttachOrphans
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::PrivAttachOrphans(Environment* ev)
- {
- FW_CPartProxyFrameIterator ite(GetPart(ev));
- for (FW_CProxyFrame* proxyFrame = ite.First(); ite.IsNotComplete(); proxyFrame = ite.Next())
- {
- if (proxyFrame->IsOrphan(ev))
- {
- this->PrivAddProxyFrame(ev, proxyFrame);
- proxyFrame->SetContainingFrame(ev, this); // Don't call RevealProxyFrame because SetContainingFrame does it
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::PrivAttachSourceFrame
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::AttachSourceFrame should not be called if sourceFrame == NULL
-
- void FW_CEmbeddingFrame::PrivAttachSourceFrame(Environment* ev, FW_CFrame* sourceFrame)
- {
- FW_ASSERT(sourceFrame != NULL);
-
- FW_CFrame::PrivAttachSourceFrame(ev, sourceFrame);
-
- // ----- If I am an embedding frame, sourceFrame must be too
- FW_CEmbeddingFrame* embeddingSourceFrame = FW_DYNAMIC_CAST(FW_CEmbeddingFrame, sourceFrame);
- FW_ASSERT(embeddingSourceFrame);
-
- // ----- Duplicate all the embedded frames of sourceFrame -----
- // ----- PrivCreateEmbeddedFrame doesn't create facets, wait for FacetAdded to duplicate my facets -----
- FW_CFrameProxyFrameIterator iter(embeddingSourceFrame);
- for (FW_CProxyFrame* proxyFrame = iter.First(); iter.IsNotComplete(); proxyFrame = iter.Next())
- {
- FW_Boolean wasInMemory = proxyFrame->IsFrameInMemory(ev);
-
- // ----- get the embedded frame -----
- ODFrame* odEmbeddedFrame = proxyFrame->GetFrame(ev);
-
- // ----- get the embedded part -----
- FW_CAcquiredODPart aqODEmbeddedPart = odEmbeddedFrame->AcquirePart(ev);
-
- // ----- Create the embedded Frame (proxyFrame) -----
- FW_CAcquiredODShape aqFrameShapeCopy(FW_CopyAndRelease(ev, odEmbeddedFrame->AcquireFrameShape(ev, NULL)));
-
- FW_CAcquiredProxyFrame aqNewProxyFrame = PrivCreateEmbeddedFrame(ev,
- kODFrameObject, // Always create embedded frames persistent
- // IsPersistent(ev) ? kODFrameObject : kODNonPersistentFrameObject,
- aqODEmbeddedPart,
- proxyFrame->GetProxy(ev), // same proxy as source
- aqFrameShapeCopy,
- NULL, // bias Canvas
- odEmbeddedFrame->GetViewType(ev),
- odEmbeddedFrame->GetPresentation(ev),
- odEmbeddedFrame->GetFrameGroup(ev),
- odEmbeddedFrame->IsOverlaid(ev),
- odEmbeddedFrame->IsSubframe(ev));
-
- // ----- Add the embedded frame to the embedded part -----
- aqODEmbeddedPart->AttachSourceFrame(ev, aqNewProxyFrame->GetFrame(ev), odEmbeddedFrame);
-
- // ----- If was not in memory close it down -----
- if (!wasInMemory)
- odEmbeddedFrame->Close(ev);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::PrivAcquireProxyFrame
- //----------------------------------------------------------------------------------------
-
- FW_CProxyFrame* FW_CEmbeddingFrame::PrivAcquireProxyFrame(Environment* ev, ODStorageUnitID frameID) const
- {
- return FW_CProxyFrame::PrivAcquireProxyFrame(ev, fProxyFrames, frameID);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::PrivRemoveEmbeddedFrame
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::PrivRemoveEmbeddedFrame(Environment* ev, FW_CProxyFrame* proxyFrame)
- {
- // If called means that the embedded frame is in memory
- // Be sure it is in memory
- ODFrame* odEmbeddedFrame = proxyFrame->GetFrame(ev);
-
- // ----- Detach the proxyframe -----
- proxyFrame->PrivDetach(ev);
-
- // ----- remove it from the proxy
- long refCount = proxyFrame->GetProxy(ev)->PrivRemoveProxyFrame(ev, proxyFrame);
-
- FW_ASSERT(refCount == 0);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::EmbeddedFrameSpec
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::EmbeddedFrameSpec(Environment *ev, ODFrame* odEmbeddedFrame, ODObjectSpec* spec)
- {
- FW_UNUSED(odEmbeddedFrame);
- FW_UNUSED(spec);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::FrameRemoved
- //----------------------------------------------------------------------------------------
- // I should not have to worry about my embedded facets because before the frame is removed
- // its facets should have been removed, removing the embedded facets
-
- void FW_CEmbeddingFrame::FrameRemoved(Environment* ev, FW_Boolean toStorage)
- {
- // ----- Collect the proxyFrames in a temporary collections -----
- FW_CPrivOrderedCollection tempCollect;
- FW_CProxyFrame* proxyFrame;
-
- FW_CFrameProxyFrameIterator ite1(this);
- for (proxyFrame = ite1.First(); ite1.IsNotComplete(); proxyFrame = ite1.Next())
- {
- tempCollect.AddLast(proxyFrame);
- }
-
- // ----- Now we can call close or remove
- FW_COrderedCollectionIterator ite2(&tempCollect);
- for (proxyFrame = (FW_CProxyFrame*)ite2.First(); ite2.IsNotComplete(); proxyFrame = (FW_CProxyFrame*)ite2.Next())
- {
- if (toStorage)
- proxyFrame->Close(ev);
- else
- this->PrivRemoveEmbeddedFrame(ev, proxyFrame);
- }
-
- // Don't have to call tempCollect.RemoveAll() because the __dt does it
-
- // ----- Call inherited -----
- FW_CFrame::FrameRemoved(ev, toStorage);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::FacetAdded
- //----------------------------------------------------------------------------------------
- // When overridden call inherited::FacetAdded FIRST
-
- void FW_CEmbeddingFrame::FacetAdded(Environment* ev, ODFacet* facet)
- {
- // ----- Call inherited first
- FW_CFrame::FacetAdded(ev, facet);
-
- // ----- Add facets to each one of my embedded frame (that are in memory) -----
- FW_CFrameProxyFrameIterator ite(this);
- for (FW_CProxyFrame* proxyFrame = ite.First(); ite.IsNotComplete(); proxyFrame = ite.Next())
- {
- PrivCreateEmbeddedFacet(ev, proxyFrame->GetProxy(ev), proxyFrame, facet);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::FacetRemoved
- //----------------------------------------------------------------------------------------
- // When overridden call inherited::FacetRemoved LAST
-
- void FW_CEmbeddingFrame::FacetRemoved(Environment* ev, ODFacet* facet)
- {
- // ----- Remove Embedded Facets
- FW_CFrameProxyFrameIterator ite(this);
- for (FW_CProxyFrame* proxyFrame = ite.First(); ite.IsNotComplete(); proxyFrame = ite.Next())
- PrivRemoveEmbeddedFacet(ev, proxyFrame, facet);
-
- // ----- Call inherited
- FW_CFrame::FacetRemoved(ev, facet);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::EmbeddedFacetAdded
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::EmbeddedFacetAdded(Environment* ev, ODFacet* odFacet)
- {
- FW_UNUSED(odFacet);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::EmbeddedFacetRemoved
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::EmbeddedFacetRemoved(Environment* ev, ODFacet* odFacet)
- {
- FW_UNUSED(odFacet);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::HasASelectedEmbeddedFacet
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEmbeddingFrame::HasASelectedEmbeddedFacet(Environment* ev) const
- {
- FW_CFrameProxyFrameIterator iter(this);
- for (FW_CProxyFrame* proxyFrame = iter.First(); iter.IsNotComplete(); proxyFrame = iter.Next())
- {
- if (proxyFrame->HasASelectedFacet(ev))
- return TRUE;
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::HandleAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEmbeddingFrame::HandleAdjustMenus(Environment* ev, FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- if (hasMenuFocus)
- {
- menuBar->EnableCommand(ev, kODCommandGetPartInfo, HasASelectedEmbeddedFacet(ev));
- menuBar->EnableCommand(ev, kODCommandOpen, HasASelectedEmbeddedFacet(ev));
-
- menuBar->EnableCommand(ev, kODCommandInsert, !GetPart(ev)->IsReadOnly(ev));
-
- #ifdef FW_BUILD_WIN
- GetPart(ev)->WinEnableEmbedMenu(ev, menuBar);
- #endif
- }
-
- return FW_CFrame::HandleAdjustMenus(ev, menuBar, hasMenuFocus, isRoot);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::HandleMenu
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEmbeddingFrame::HandleMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Boolean result = TRUE;
- ODCommandID commandID = theMenuEvent.GetCommandID(ev);
-
- #ifdef FW_BUILD_WIN
- ODPart *embeddedPart = GetPart(ev)->WinCreateEmbeddedPartFromCommand(ev, commandID);
- if (embeddedPart != NULL)
- {
- this->EmbedSingleFrame(ev, embeddedPart, NULL, NULL);
- return TRUE;
- }
- #endif
-
- FW_CSelection* selection = this->GetPresentation(ev)->GetSelection(ev);
- switch (commandID)
- {
- case kODCommandInsert:
- if (selection)
- {
- FW_ASSERT(!GetPart(ev)->IsReadOnly(ev));
- FW_ASSERT(FW_DYNAMIC_CAST(FW_CEmbeddingSelection, selection));
- result = ((FW_CEmbeddingSelection*)selection)->InsertNewPart(ev, this);
- }
- else
- FW_Beep();
- break;
-
- case kODCommandGetPartInfo:
- ShowPartInfo(ev);
- break;
-
- case kODCommandOpen:
- OpenSelection(ev);
- break;
-
- default:
- result = FW_CFrame::HandleMenu(ev, theMenuEvent);
- };
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::OpenSelection
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::OpenSelection(Environment* ev)
- {
- // I need to collect first the proxyframe that I want to open because opening the first
- // window will unselect the other one
-
- FW_CProxyFrame* proxyFrame;
- FW_CPrivOrderedCollection temp;
-
- FW_CFrameProxyFrameIterator iter(this);
- for (proxyFrame = iter.First(); iter.IsNotComplete(); proxyFrame = iter.Next())
- {
- if (proxyFrame->HasASelectedFacet(ev))
- temp.AddLast(proxyFrame);
- }
-
- FW_COrderedCollectionIterator iter2(&temp);
- for (proxyFrame = (FW_CProxyFrame*)iter2.First(); iter2.IsNotComplete(); proxyFrame = (FW_CProxyFrame*)iter2.Next())
- {
- ODFrame* embeddedFrame = proxyFrame->GetFrame(ev);
- FW_CAcquiredODPart aqODPart = embeddedFrame->AcquirePart(ev);
- aqODPart->Open(ev, embeddedFrame);
- }
-
- // the destructor of temp will call RemoveAll
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::ShowPartInfo
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::ShowPartInfo(Environment* ev)
- {
- FW_CFrameProxyFrameIterator iter(this);
- for (FW_CProxyFrame* proxyFrame = iter.First(); iter.IsNotComplete(); proxyFrame = iter.Next())
- {
- if (proxyFrame->HasASelectedFacet(ev))
- {
- FW_MProxy *proxy = proxyFrame->GetProxy(ev);
- FW_ASSERT(proxy);
-
- // ----- Try first the active facet -----
- ODFacet* facet = this->GetActiveFacet(ev);
-
- // ----- If not Active facet try the first facet -----
- if (facet == NULL)
- {
- FW_CFrameFacetIterator iteFrame(ev, this);
- facet = iteFrame.First(ev);
- }
- FW_ASSERT(facet != NULL);
-
- // [HLX] We are passing the first facet but we need to be a little bit more smart
- // about that. We should pass the selected one or if there is no selection do it on ourself
- FW_CEmbeddedODFacetsIterator ite(ev, proxy, facet, kODFrontToBack);
- ODFacet* firstEmbeddedFacet = ite.First(ev);
- FW_ASSERT(firstEmbeddedFacet != NULL);
-
- ODFrame* embeddedFrame = proxyFrame->GetFrame(ev);
- ODTypeToken oldViewType = embeddedFrame->GetViewType(ev);
-
- ODInfo* info = GetPart(ev)->GetSession(ev)->GetInfo(ev);
- info->ShowPartFrameInfo(ev, firstEmbeddedFacet, !GetPart(ev)->IsReadOnly(ev));
-
- ODTypeToken newViewType = embeddedFrame->GetViewType(ev);
-
- // ----- Propagate the view type to other sibling frames -----
- if (oldViewType != newViewType && GetPresentation(ev)->UseSameViewTypeForEmbeddedFrames(ev))
- {
- FW_CProxyEmbeddedFrameIterator iter2(ev, proxy);
- for (ODFrame* sibling = iter2.First(ev); iter2.IsNotComplete(ev); sibling = iter2.Next(ev))
- {
- if (sibling->GetViewType(ev) != newViewType)
- sibling->ChangeViewType(ev, newViewType);
- }
- }
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::RevealFrame
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEmbeddingFrame::RevealFrame(Environment *ev,
- ODFrame* embeddedFrame,
- ODShape* revealShape)
- {
- FW_UNUSED(embeddedFrame);
- FW_UNUSED(revealShape);
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::CountProxyFrames
- //----------------------------------------------------------------------------------------
-
- unsigned long FW_CEmbeddingFrame::CountProxyFrames(Environment* ev) const
- {
- return fProxyFrames->Count();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::PrivAddProxyFrame
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::PrivAddProxyFrame(Environment* ev, FW_CProxyFrame* proxyFrame)
- {
- #ifdef FW_DEBUG
- FW_CFrameProxyFrameIterator ite(this);
- for (FW_CProxyFrame* pf = ite.First(); ite.IsNotComplete(); pf = ite.Next())
- {
- if (pf == proxyFrame)
- FW_DEBUG_MESSAGE("FW_CEmbeddingFrame::PrivAddProxyFrame ProxyFrame already attached");
- }
- #endif
-
- fProxyFrames->AddLast(proxyFrame);
- proxyFrame->Acquire();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::ViewTypeChanged
- //----------------------------------------------------------------------------------------
-
- void FW_CEmbeddingFrame::ViewTypeChanged(Environment* ev, ODTypeToken newViewType, ODTypeToken oldViewType)
- {
- FW_CFrame::ViewTypeChanged(ev, newViewType, oldViewType);
-
- FW_CFrameProxyFrameIterator ite(this);
- for (FW_CProxyFrame* proxyframe = ite.First(); ite.IsNotComplete(); proxyframe = ite.Next())
- {
- if (oldViewType == FW_CPart::gViewAsFrameToken)
- PrivRemoveEmbeddedFacets(ev, proxyframe);
- else
- PrivCreateEmbeddedFacets(ev, proxyframe->GetProxy(ev), proxyframe);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::PrivRemoveProxyFrame
- //----------------------------------------------------------------------------------------
-
- long FW_CEmbeddingFrame::PrivRemoveProxyFrame(Environment* ev, FW_CProxyFrame* proxyFrame)
- {
- fProxyFrames->Remove(proxyFrame);
- return proxyFrame->Release();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::AdjustCursor
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEmbeddingFrame::AdjustCursor(Environment *ev, ODFacet* odFacet, const FW_CPoint& theMousePoint)
- {
- // ----- Test if mouse on the active border of an embedded facet -----
- FW_Boolean cursorInActiveBorder = FALSE;
-
- ODArbitrator* arbitrator = GetPart(ev)->GetSession(ev)->GetArbitrator(ev);
- FW_CAcquiredODFrame aqActiveFrame = arbitrator->AcquireFocusOwner(ev, FW_CPart::gMenuFocusToken);
- if (aqActiveFrame != NULL)
- {
- FW_CODFrameFacetIterator iter(ev, aqActiveFrame);
-
- FW_CAcquiredODTransform aqWindowFrameXForm = odFacet->AcquireWindowFrameTransform(ev, NULL);
- FW_CPoint windowMouse = theMousePoint.TransformCopy(ev, aqWindowFrameXForm);
-
- for (ODFacet* facet = iter.First(ev); iter.IsNotComplete(ev); facet = iter.Next(ev))
- {
- FW_CAcquiredODTransform aqxForm = facet->AcquireWindowFrameTransform(ev, NULL);
- ODPoint odFramePoint = windowMouse.InverseTransformCopy(ev, aqxForm);
-
- if (facet->ActiveBorderContainsPoint(ev, &odFramePoint, NULL))
- {
- cursorInActiveBorder = TRUE;
- break;
- }
- }
- }
-
- if (cursorInActiveBorder)
- FW_gOpenHandCursor.Select();
-
- return cursorInActiveBorder;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::GetEmbeddedFacet
- //----------------------------------------------------------------------------------------
- // Return the <first> facet belonging to proxy embedded in 'facet'
-
- ODFacet* FW_CEmbeddingFrame::GetEmbeddedFacet(Environment* ev, ODFacet* facet, FW_MProxy* proxy)
- {
- FW_CFacetIterator i(ev, facet, kODChildrenOnly, kODFrontToBack);
-
- for (ODFacet* embeddedFacet = i.First(ev); i.IsNotComplete(ev); embeddedFacet = i.Next(ev))
- {
- FW_CAcquiredODPart aqODPart = embeddedFacet->GetFrame(ev)->AcquirePart(ev);
- if (aqODPart == proxy->GetEmbeddedPart(ev))
- return embeddedFacet;
- }
-
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::CanAcceptDrop
- //----------------------------------------------------------------------------------------
- // This is much simpler if we are an embedding part. We can accept just about anything
- // Don't forget, CanAcceptDrop is not called if read only.
-
- ODDragResult FW_CEmbeddingFrame::CanAcceptDrop(Environment *ev, ODDragItemIterator* dragInfo)
- {
- FW_UNUSED(ev);
- FW_UNUSED(dragInfo);
-
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEmbeddingFrame::ODtoFWFrame
- //----------------------------------------------------------------------------------------
-
- FW_CEmbeddingFrame* FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(Environment* ev, ODFrame* odFrame)
- {
- FW_CEmbeddingFrame* frame = NULL;
-
- if (odFrame)
- {
- FW_CFramePartInfo* framePartInfo = (FW_CFramePartInfo*)odFrame->GetPartInfo(ev);
- frame = framePartInfo ? FW_DYNAMIC_CAST(FW_CEmbeddingFrame, framePartInfo->GetFrame()) : NULL;
- }
-
- return frame;
- }
-
-